package com.lut.teacher.teacherservice.controller;

import java.util.Arrays;
import java.util.Map;

import com.lut.teacher.teacherservice.utils.PageUtils;
import com.lut.teacher.teacherservice.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lut.teacher.teacherservice.entity.IndexesEntity;
import com.lut.teacher.teacherservice.service.IndexesService;




/**
 * 
 *
 * @author tongyerui
 * @email tongyerui@gmail.com
 * @date 2021-07-06 11:31:08
 */
@RestController
@RequestMapping("teacherservice/indexes")
public class IndexesController {
    @Autowired
    private IndexesService indexesService;

    /**
     * 列表
     */
    @RequestMapping("/list")
   // @RequiresPermissions("teacherservice:indexes:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = indexesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("teacherservice:indexes:info")
    public R info(@PathVariable("id") Integer id){
		IndexesEntity indexes = indexesService.getById(id);

        return R.ok().put("indexes", indexes);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
   // @RequiresPermissions("teacherservice:indexes:save")
    public R save(@RequestBody IndexesEntity indexes){
		indexesService.save(indexes);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("teacherservice:indexes:update")
    public R update(@RequestBody IndexesEntity indexes){
		indexesService.updateById(indexes);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("teacherservice:indexes:delete")
    public R delete(@RequestBody Integer[] ids){
		indexesService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
